package com.lei.mvp_retrofitlibrary.mvp.view;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.lei.mvp_retrofitlibrary.mvp.presenter.IPresenter;

/**
 * @ProjectName : YoHuo001Java
 * @Author : 雷金泷
 * @Time : 2020/12/13 19:08
 * @Description : 文件描述
 */
public abstract class BaseFragment<P extends IPresenter> extends Fragment implements IFragment,IView {

    protected View mView;

    protected P mPresenter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return mView = inflater.inflate(bindlayout(),container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
        initData();
    }

    @Override
    public void showLayout() {

    }

    @Override
    public void hideLayout() {

    }

    @Override
    public <T extends View> T findViewById(int Byid) {
        return mView.findViewById(Byid);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter!=null){
            mPresenter.destroy();
            mPresenter = null;
        }
    }
}
